package com.ruoyi.project.charging.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.charging.domain.CChargingDevice;
import com.ruoyi.project.charging.service.ICChargingDeviceService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 岸电设备数据Controller
 * 
 * @author Yaoxuan Mo
 * @date 2025-07-28
 */
@RestController
@RequestMapping("/charging/device")
public class CChargingDeviceController extends BaseController
{
    @Autowired
    private ICChargingDeviceService cChargingDeviceService;

    /**
     * 查询岸电设备数据列表
     */
    @PreAuthorize("@ss.hasPermi('charging:device:list')")
    @GetMapping("/list")
    public TableDataInfo list(CChargingDevice cChargingDevice)
    {
        startPage();
        List<CChargingDevice> list = cChargingDeviceService.selectCChargingDeviceList(cChargingDevice);
        return getDataTable(list);
    }

    /**
     * 导出岸电设备数据列表
     */
    @PreAuthorize("@ss.hasPermi('charging:device:export')")
    @Log(title = "岸电设备数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CChargingDevice cChargingDevice)
    {
        List<CChargingDevice> list = cChargingDeviceService.selectCChargingDeviceList(cChargingDevice);
        ExcelUtil<CChargingDevice> util = new ExcelUtil<CChargingDevice>(CChargingDevice.class);
        util.exportExcel(response, list, "岸电设备数据数据");
    }

    /**
     * 获取岸电设备数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('charging:device:query')")
    @GetMapping(value = "/{deviceId}")
    public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId)
    {
        return success(cChargingDeviceService.selectCChargingDeviceByDeviceId(deviceId));
    }

    /**
     * 新增岸电设备数据
     */
    @PreAuthorize("@ss.hasPermi('charging:device:add')")
    @Log(title = "岸电设备数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CChargingDevice cChargingDevice)
    {
        return toAjax(cChargingDeviceService.insertCChargingDevice(cChargingDevice));
    }

    /**
     * 修改岸电设备数据
     */
    @PreAuthorize("@ss.hasPermi('charging:device:edit')")
    @Log(title = "岸电设备数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CChargingDevice cChargingDevice)
    {
        return toAjax(cChargingDeviceService.updateCChargingDevice(cChargingDevice));
    }

    /**
     * 删除岸电设备数据
     */
    @PreAuthorize("@ss.hasPermi('charging:device:remove')")
    @Log(title = "岸电设备数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deviceIds}")
    public AjaxResult remove(@PathVariable Long[] deviceIds)
    {
        return toAjax(cChargingDeviceService.deleteCChargingDeviceByDeviceIds(deviceIds));
    }
}
